<?php

require_once '../mysqlConnect.php';

function retrieveMedicalTestAnswers() {
	
	$conn = GetPDOConnection();
	
	$sql = "SELECT * FROM Test ORDER BY ID";
	$STH = $conn->prepare($sql);
	$STH->setFetchMode(PDO::FETCH_ASSOC);
	$STH->execute();
	$results = $STH->fetchAll();
	
	$conn = null;
	return $results;
}

function retrieveMedicalTestQuestions () {

	$conn = GetPDOConnection();

	$sql = "SELECT * FROM medical_test_questions WHERE text != 'Date of Test Record' ORDER BY qnumber";
	$STH = $conn->prepare($sql);
	$STH->setFetchMode(PDO::FETCH_ASSOC);
	$STH->execute();
	$symptoms = $STH->fetchAll();

	foreach ($symptoms as $key => $symptomInfo) {
		if ($symptomInfo['type'] == 5)
			$symptoms[$key]["answer_options"] = retrieveMedicalTestAnswers();
		elseif ($symptomInfo['type'] == 1)
			$symptoms[$key]["answer_options"] = getDropDownOptions($symptomInfo['type_options']);
		
	}

	$conn = null;
	return $symptoms;
}